#ifndef __COMMON_QUEUE_H_
#define __COMMON_QUEUE_H_

#include "typedef.h"
#define _IS_QUEUE__ 0xAABBCCDD

typedef struct QueueNode
{
    struct QueueNode *next;
    struct QueueNode *prev;
    address queue;
} *QueueNode;


typedef struct Queue
{
    QueueNode first;
    QueueNode last;
    word magic;
    int num;
    boolean (*isEmpty)();
} *Queue;

// decalre and define a queue
#define DEFINE_QUEUE(varname)                           \
    struct Queue varname##_ins = {.magic = _IS_QUEUE__, \
                                  .num = 0,             \
                                  .first = NULL,        \
                                  .last = NULL};        \
    Queue varname = &varname##_ins;

static inline boolean isQueue(void* object)
{
    return CAST_AS(Queue,object)->magic == _IS_QUEUE__;
}

// static inline boolean isEmpty

#endif//__COMMON_QUEUE_H_